package org.oep.widgets;

public class Utils {
	public static String [] tokenize(String s) {
		return tokenize(s, ' ');
	}
	
	public static String [] tokenize(String s, char delimiter) {
		int spaceCount = 0;
		for(int i = 0; i < s.length(); i++)
			if(s.charAt(i) == delimiter) spaceCount++;
		String [] tokens = new String [spaceCount + 1];
		String tmp = new String();
		int index = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) != delimiter)
				tmp += s.charAt(i);
			else {
				tokens[index] = tmp;
				tmp = "";
				index++;
			}
		}
		tokens[ tokens.length - 1 ] = tmp;
		return tokens;
	}
}
